package com.example.kt_base.s5

import java.io.File

//TODO 85.Kotlin语言的类型转换
open class Person2(private val name:String){
     fun showName()="父类的姓名是【$name】"

    //Kt所有的函数，默认是final修饰的，不能被继承，和Java相反
    open fun myPrintln()= println(showName())
}

class Student2(private val subName:String):Person2(subName){
    fun showName2()="子类的姓名是【$subName】"
    override fun myPrintln()= println(showName2())

}
fun main() {
    val p:Person2 =Student2("张三")
    p.myPrintln()

    println(p is Person2)
    println(p is Student2)
    println(p is File)

    if (p is Student2){
        p.myPrintln()

    }

    if (p is Person2){
        println(p.showName())
    }



}